# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Arch Haskell Team <arch-haskell@haskell.org>

_hkgname=http-client-tls
pkgname=haskell-http-client-tls
pkgver=0.3.6.1
pkgrel=93
pkgdesc="http-client backend using the connection package and tls library"
url="https://github.com/snoyberg/http-client"
license=("MIT")
arch=('loong64' 'x86_64')
depends=('ghc-libs' "haskell-case-insensitive" "haskell-connection" "haskell-cryptonite"
         "haskell-data-default-class" "haskell-http-client"
         "haskell-http-types" "haskell-memory" "haskell-network" "haskell-network-uri"
         "haskell-tls")
makedepends=('ghc')
source=("https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz")
sha512sums=('81b6e9ad3956f237bec83173ab8ac153ea3e9b555f0a84dc6ec0a13f6ad96dfc104d61125b66fc8733c8d8c3b7f8fc5e89cfcb885a7352f3af2e2b5473732294')

build() {
    cd $_hkgname-$pkgver
    
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
